package com.servitware.cr.crdoc;

import java.util.concurrent.CountDownLatch;

import org.apache.log4j.PropertyConfigurator;

import com.servitware.cardio.config.Configuratio;
import com.servitware.cr.crdoc.view.MainView;
import com.servitware.util.view.ViewUtil;


public class App
{

    private Configuratio cfg = null;
    private ConfigMng cfgMng = null;
    private MainView mainView = null;
    
    public App()
    {
    }

    public void run() throws InterruptedException
    {
        /*
         * crea configManager
         */
        cfgMng = ConfigMng.getInstance();

        
        /*
         * check config and get signaling latch to start
         * dokStat after the configurer
         */
        CountDownLatch latch = cfgMng.checForConfig();
        

        /*
         * DokStat 
         * --
         * MainView
         */ 
        mainView = new MainView(latch, cfgMng);
        ViewUtil.centerWindy(mainView);

        java.awt.EventQueue.invokeLater(new Runnable()
        {
            public void run()
            {
                mainView.setVisible(true);
            }
        });
        
    }

    public static void main(String[] args) throws InterruptedException
    {
    	
    	String log4jConfPath = "/servitware-cardio/src/test/resources/log4j.properties";
    	PropertyConfigurator.configure(log4jConfPath);
        App app = new App();
        app.run();
    }

}
